<?php
class Upload_extend {
	/**
	 * 获取hash值
	 * @param unknown_type $appid
	 * @param unknown_type $secret
	 */
	public static function hash($app, $secret, $arr = array()) {
		$args = array(
			'app' => $app,
			'random' => Func::randstr(6),
			'params' => http_build_query($arr)
		);
		$string = http_build_query($args, '', '&');
		$return = Func::authcode($string, $operation = 'ENCODE', $secret);
		return $return;
	}
	/**
	 * 验证hash值
	 * @param unknown_type $appid
	 * @param unknown_type $secret
	 * @param unknown_type $hash
	 */
	public static function auth($app, $secret, $hash, $arr = array()) {
		$decode = Func::authcode($hash, $operation = 'DECODE', $secret);
		if(!$decode) return false;
		parse_str($decode, $args);
		return $app == $args['app'] && http_build_query($arr) == $args['params'];
	}
	public static function ext($upload) {
		
	}
}